﻿namespace DotNetUtility.ExtensionMethods.Test
{
    using NUnit.Framework;
    using DotNetUtility.ExtensionMethods;

    [TestFixture]
    public class StringExtensionsTest
    {
        [Test]
        public void JoinWithSingleParameter()
        {
            string baseItem = "Please add with";
            string itemToJoin = " Me";
            string expectedResultAfterJoin = "Please add with Me";
            Assert.AreEqual(expectedResultAfterJoin, baseItem.JoinWith(itemToJoin));
        }

        [Test]
        public void JoinWithDoubleParameters()
        {
            string baseItem = "Please add with";
            string firstItemToJoin = " First";
            string secondItemToJoin = " and Second";
            string expectedResultAfterJoin = "Please add with First and Second";
            Assert.AreEqual(expectedResultAfterJoin, baseItem.JoinWith(firstItemToJoin, secondItemToJoin));
        }
        [Test]
        public void ToBooleanFromAnyText()
        {
            //string itemToBoolean = "Please add with";
            //object expectedResultAfterJoin = null;
            string itemToBoolean = "one";
            object expectedResultAfterJoin = true;
            Assert.AreEqual(expectedResultAfterJoin, itemToBoolean.ToBooleanFromAnyText());
        }

        [Test]
        public void IsParsableToBoolean()
        {
            string booleanTextToTest = "hello";
            bool expectedResult = false;
            Assert.AreEqual(expectedResult, booleanTextToTest);
        }

        [Test]
        public void ToBoolean()
        {
            string booleanToTest = "true";
            object expectedResult = true;
            Assert.AreEqual(expectedResult, booleanToTest.ToBoolean());
        }

        [Test]
        public void ConvertToBooleanTextIfPossible()
        {
            string textToTest = "1";
            string expectedResult = "One";
            Assert.AreEqual(expectedResult, textToTest.ConvertToBooleanTextIfPossible());
        }

    }
}
